import * as g_cookie from '../../cache/app_cookie'
import * as g_session from '../../cache/app_session'
import * as  app_constants from '../constants/app_constants'
const app = {
    state: {
        language: g_cookie.get_cookie(app_constants.LANG_KEY) || app_constants.DEFAULT_LANG,
        app_source_key: g_session.getLocalCache(app_constants.APP_SOURCE_KEY)
    },
    mutations: {
        SET_APP_LANG: (state, lang) => {
            state.language = lang
            g_cookie.set_cookie(app_constants.LANG_KEY,lang)
        },
        SET_APP_KEY: (state, app_key) => {
            state.app_source_key = app_key
            g_session.setLocalCache(app_constants.APP_SOURCE_KEY)
        }
    },
    //和mutations同一级别，但是actions可以做异步的操作
    actions: {

    }
}

export default app